﻿public partial class Controls_Content_MainMenu : BaseControl
{
    protected override void DoInitialize(object data, bool loadData)
    {
        rpMenu.DataSource = CurrentPage.MetaDataList;
        rpMenu.DataBind();
    }

    protected string GetActiveClass(string view, SitePage pPage)
    {
        var cssClass = string.Empty;
        if (string.IsNullOrEmpty(view))
        {
            if (CurrentPage.CurrentSitePage == pPage)
                cssClass = "current";
        }
        else
        {
            if (CurrentView == view)
            {
                cssClass = "current";
            }
            else
            {
                if (IsMenuView(view))
                    cssClass = "current";
            }
        }
        return cssClass;
    }

    private bool IsMenuView(string view)
    {
        var element = CurrentPage.Breadcrumbs.Find(b => b.ParentView == view);
        if (element != null)
        {
            return CurrentView == element.View || IsMenuView(element.View);
        }
        return false;
    }
}